package com.example.spindrift.service;

import com.example.spindrift.dao.UseHistoryMapper;
import com.example.spindrift.models.SysSong;
import com.example.spindrift.models.UseHistory;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HistoryService {
    @Autowired
    UseHistoryMapper useHistoryMapper;

    public List<UseHistory> getAllHistory(){
        return useHistoryMapper.getAllHistory();
    }
    public List<SysSong> getHistorySongByUser(Integer userId){
        return useHistoryMapper.getHistorySongByUser(userId);
    }

    /**
     * 根据用户ID，歌曲名称关键字查询播放历史信息歌曲信息
     * @param userId 用户ID
     * @param keyword 关键字
     * @return
     */
    public List<SysSong> searchHistory(Integer userId,String keyword){
        return useHistoryMapper.searchHistory(userId,keyword);
    }
    public Integer insertHistory(UseHistory history){
        return useHistoryMapper.insertHistory(history);
    }
    public Integer deleteHistoryByUser(Integer userId){
        return useHistoryMapper.deleteHistoryByUser(userId);
    }
    public Integer deleteHistoryBySong(Integer songId){
        return useHistoryMapper.deleteHistoryBySong(songId);
    }
}
